package com.migraine.mapper;

import com.migraine.model.Rooms;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface RoomsMapper {
    int deleteByPrimaryKey(String roomid);

    int insert(Rooms record);

    int insertSelective(Rooms record);

    Rooms selectByPrimaryKey(String roomid);

    int updateByPrimaryKeySelective(Rooms record);

    int updateByPrimaryKey(Rooms record);

    @Insert("insert into rooms(roomid,roomname,creator,createtime,upperlimits,type,password,secret) values  (#{id},#{roomname},#{creator},#{date},#{limit},#{type},#{password},#{secret})")
    boolean insertRoom(int id, String roomname, String creator, Date date, int limit, int type, String password, int secret);

    @Delete("delete from rooms where roomid=#{id}")
    boolean deleteRoom(int id);

    @Select("select type from rooms where roomid=#{id}")
    Integer getRoomType(int id);

    @Select("select roomid from rooms")
    List<Integer> getAllId();

    @Select("select * from rooms order by createtime desc")
    List<Rooms> getAllRooms();

    @Select("select * from rooms where roomid=#{roomId}")
    Rooms getRoomsById(int roomId);

    @Select("select password from rooms where roomid=#{roomId}")
    String getRoomPasswordById(String roomId);
}